package com.wanxi.user.api;

import com.wanxi.user.domain.dto.AddressDefaultDto;
import com.wanxi.user.domain.dto.AddressDto;
import com.wanxi.user.domain.entity.Address;
import com.wanxi.user.domain.result.UserResult;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author:Iny
 * @Data：2022/1/10 10:03
 */
@FeignClient(value = "user",path = "/back/address")
public interface AddressFeign {

    /**
     *
     * @param userId 用户id
     * @return
     */
    @ApiOperation(value="通过用户id查看收获地址")
    @GetMapping("/findAddress")
    UserResult<List<Address>> findByUserId(@RequestParam("userId") long userId);

    /**
     *
     * @param addressDto 收获地址信息
     * @return
     */
    @ApiOperation(value="通过用户id添加收获地址")
    @PostMapping("/addAddress")
    UserResult<Long> addAddress(@RequestBody AddressDto addressDto);

    /**
     *
     * @param addressDefaultDto 收获地址id和用户id
     * @return
     */
    @ApiOperation(value="通过收货地址id修改收获地址默认值")
    @PutMapping("/updateAddressDefault")
    UserResult<Boolean> updateAddressDefault(@RequestBody AddressDefaultDto addressDefaultDto);

    /**
     *
     * @param addressDto 收获地址信息
     * @return
     */
    @ApiOperation(value="通过收货地址id修改收获地址")
    @PutMapping("/updateAddress")
    UserResult<Boolean> updateAddress(@RequestBody AddressDto addressDto);

    /**
     *
     * @param id 收获地址id
     * @return
     */
    @ApiOperation(value="通过收货地址id删除收获地址")
    @ApiImplicitParam(name = "id",value = "收获地址id",dataType = "long",required = true)
    @PutMapping("/delAddress")
    UserResult<Boolean> delAddress(@RequestParam("id") long id);

    /**
     * 通过收获地址id查询收获地址信息
     * @param id 收货地址id
     * @return
     */
    @ApiOperation(value="通过收货地址查询收获地址")
    @ApiImplicitParam(name = "id",value = "收获地址id",dataType = "long",required = true)
    @GetMapping("/findAddressById")
    UserResult<Address> findAddressById(@RequestParam("id") long id);
}
